package com.ddxcloud.movie.controller;

import com.ddxcloud.movie.service.WechatRefundService;
import com.github.binarywang.wxpay.exception.WxPayException;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/refund")
@Api(tags = "退款")
public class RefundController {

    @Resource
    WechatRefundService wechatRefundService;

    /**
     * 退款回调
     * @param request
     * @param response
     * @return
     * @throws WxPayException
     * @throws IOException
     */
    @Operation(summary = "退款回调", hidden = true)
    @PostMapping("/notify")
    public Map<String, String> notify(HttpServletRequest request, HttpServletResponse response) throws WxPayException, IOException {
        return wechatRefundService.notify(request, response);
    }
}
